package exam.microsoft.first.task1;

import java.util.Arrays;

/**
 * @Author: 18362
 * @Create: 2022-08-19 18:56:48 星期五
 */
class Solution {
    public int solution(int[] X, int[] Y, int W) {
        Arrays.sort(X);
        int n = X.length, cur = 0, res = 0;
        while (cur < X.length) {
            int end = cur;
            while (end < X.length) {
                if (X[end] > X[cur] + W)
                    break;
                end++;
            }
            res++;
            cur = end;
        }
        return res;
    }
}